package org.jackysoft.struts2.business;

import java.util.Collection;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.jackysoft.entity.Department;
import org.jackysoft.entity.DepartmentType;
import org.jackysoft.entity.Technics;
import org.jackysoft.service.DepartmentService;
import org.jackysoft.service.TechnicsService;
import org.jackysoft.struts2.UtilsCRUDAction;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;

@Namespace("/technics")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class TechnicsAction extends UtilsCRUDAction<Technics> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5601756953453132010L;
	private TechnicsService service;
	private DepartmentService deptService;
	private Technics bean;
	private Collection<Technics> beans;
	private Collection<Department> groups;

	public String input() throws Exception {
		beans = service.getsByProduct(bean.getProduct());
		groups = deptService.getsByType(DepartmentType.Manufacture);
		return INPUT;
	}

	public void setBean(Technics bean) {
		this.bean = bean;
	}

	public Technics getBean() {
		return this.bean;
	}

	public void setBeans(Collection<Technics> beans) {

		this.beans = beans;
	}

	public Collection<Technics> getBeans() {
		return this.beans;
	}

	@Resource
	public void setService(TechnicsService service) {
		this.service = service;
		this.setDataProvider(service);
	}

	public TechnicsService getService() {
		return this.service;
	}

	@Resource
	public void setDeptService(DepartmentService deptService) {
		this.deptService = deptService;
	}

	public Collection<Department> getGroups() {
		return groups;
	}

	public void setGroups(Collection<Department> groups) {
		this.groups = groups;
	}

}